package cn.com.cetccst.tools.notification;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.media.RingtoneManager;

import androidx.core.app.NotificationCompat;

import java.util.Objects;

public class NotificationUtil {

    public static int getNotificationId(String channelId) {
        return Objects.hash(channelId);
    }

    public static NotificationChannel generateChannel(String channelId) {
        NotificationChannel channel = new NotificationChannel(
                channelId,
                channelId,
                NotificationManager.IMPORTANCE_DEFAULT);
        return channel;
    }
    public static Notification generateNotification(Context context, String channelId, String title, String description, int drawableId, PendingIntent pendingIntent) {
        Notification notification = new NotificationCompat.Builder(context, channelId)
                .setContentTitle(title)
                .setSmallIcon(drawableId)
                .setAutoCancel(true)
                .setContentText(description)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(description))
                .setContentIntent(pendingIntent)
                .setPriority(NotificationCompat.PRIORITY_MAX)
                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .build();
        return notification;
    }
}
